﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Profari_Heldur_Utan_Um_Prof
{
    public partial class TesterInterface : Form
    {
        

        public TesterInterface()
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterScreen;
        }

        #region Buttons
        private void btnQuitProject_Click(object sender, EventArgs e)
        {
            //Closes the project if yes button is pressed
            DialogResult quitProject = MessageBox.Show("Are you sure you want to quit the program?", "Quit", MessageBoxButtons.YesNo);
            if (quitProject == DialogResult.Yes)
            {
                Application.Exit();
            }
        }

        private void btnNewProject_Click(object sender, EventArgs e)
        {         
            //Moves to the first window when user wants to create new project. 
            //In that window he chooses name for the project
            resetStaticVariables();
            System.Threading.Thread projectName = new System.Threading.Thread(new System.Threading.ThreadStart(OpenCreateTask));
            projectName.SetApartmentState(System.Threading.ApartmentState.STA);
            projectName.Start();
            this.Close();
        }

        private void btnOldProjects_Click(object sender, EventArgs e)
        {
            resetStaticVariables();
            //This moves the user to the window where he can choose which project to look at and then edit if he wishes
            System.Threading.Thread listOfGroups = new System.Threading.Thread(new System.Threading.ThreadStart(OpenListOfProjects));
            listOfGroups.SetApartmentState(System.Threading.ApartmentState.STA);
            listOfGroups.Start();
            this.Close();
        }

        private void btnStartEvaluation_Click(object sender, EventArgs e)
        {
            resetStaticVariables();
            System.Threading.Thread openStartChooseProject = new System.Threading.Thread(new System.Threading.ThreadStart(OpenStartChooseProject));
            openStartChooseProject.SetApartmentState(System.Threading.ApartmentState.STA);
            openStartChooseProject.Start();
            this.Close();
        }
        #endregion

        //The static variables in the forms that follows the "New Project" button are set to null.
        private void resetStaticVariables()
        {
            CreateTask.globalGroupID = 0;
            CreateTask.radCreateGroupNameValue = 0;
            CreateTask.radSelectGroupNameValue = 0;
            CreateTask.cmbSelectGroupNameValue = "";
            CreateTask.txtCreateGroupNameValue = "";
            CreateTask.txtEvaluationNameValue = "";
            CreateTask.txtWebPageValue = "";
            CreateTask.txtTaskNameValue = "";
            CreateTask.riTaskDescriptionValue = "";
            CreateTask.riTaskScenarioValue = "";
            CreateTask.chkDescriptionTaskValue = 0;

            CheckBoxes.chkIntroSessionValue = 0;
            CheckBoxes.chkInfoUserBeforeValue = 0;
            CheckBoxes.chkNameValue = 0;
            CheckBoxes.chkSsnValue = 0;
            CheckBoxes.chkMobileValue = 0;
            CheckBoxes.chkAddressValue = 0;
            CheckBoxes.chkGenderValue = 0;
            CheckBoxes.chkBirthYearValue = 0;
            CheckBoxes.chkOtherValue = 0;
            CheckBoxes.chkInfoUserAfterValue = 0;
            CheckBoxes.chkRadQuestions = 0;
            CheckBoxes.radEssayValue = 0;
            CheckBoxes.radSurveyValue = 0;
            CheckBoxes.txtEmailValue = "";
            CheckBoxes.chkEmailValue = 0;
            CheckBoxes.chkUserFeedback = 0;

            IntroductionText.introText = "";
        }

        //The Open forms functions makes it able to move between forms and close the first form when the second one is opened
        #region OpenForms
        public static void OpenCreateTask()
        {
           Application.Run(new CreateTask());//Create an instance of your new form. No need to call show method.
        }

        public static void OpenListOfProjects()
        {
           Application.Run(new ListOfProjects());
        }

        public static void OpenStartChooseProject()
        {
            Application.Run(new StartChooseProject());
        }

        #endregion
    }
}
